package org.nlp2rdf.navigator.client.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * DTO contains information about the knowledge base
 * 
 * @author Sebastian Hellmann <hellmann@informatik.uni-leipzig.de>
 */
@SuppressWarnings("serial")
public class KnowledgeBaseDescriptorDTO implements Serializable {
	private String kbId;

	private String applicationLabel;
	private String applicationComment;

	private String kbLabel;
	private String kbComment;
	private Map<String, String> links = new LinkedHashMap<String, String>();

	private String exampleLabel = null;
	private String exampleComment = null;
	private List<SearchDescriptorDTO> availableSearches = new ArrayList<SearchDescriptorDTO>();

	@Override
	public String toString() {
		return kbId + "|" + exampleLabel + "|" + exampleComment;
	}

	public String getApplicationComment() {
		String ret = applicationComment;
		if (!links.isEmpty()) {
			StringBuffer buf = new StringBuffer(applicationComment);
			buf.append("Links: ");
			for (Iterator<String> it = links.keySet().iterator(); it.hasNext();) {
				String key = it.next();
				buf.append("<a target=\"_blank\" href=\"" + key + "\">");
				buf.append(links.get(key) + "</a> ");
				buf.append((it.hasNext())?" | ":"");
			}
			ret = buf.toString();
		}
		return  ret;
	}

	public String getKbComment() {
		return kbComment;
	}

	public String getKbId() {
		return kbId;
	}

	public void setKbId(String kbId) {
		this.kbId = kbId;
	}

	public String getApplicationLabel() {
		return applicationLabel;
	}

	public void setApplicationLabel(String applicationLabel) {
		this.applicationLabel = applicationLabel;
	}

	public void setApplicationComment(String applicationComment) {

		this.applicationComment = applicationComment;
	}

	public String getKbLabel() {
		return kbLabel;
	}

	public void setKbLabel(String kbLabel) {
		this.kbLabel = kbLabel;
	}

	public void setKbComment(String kbComment) {
		this.kbComment = kbComment;
	}

	public String getExampleLabel() {
		return exampleLabel;
	}

	public void setExampleLabel(String exampleLabel) {
		this.exampleLabel = exampleLabel;
	}

	public String getExampleComment() {
		return exampleComment;
	}

	public void setExampleComment(String exampleComment) {
		this.exampleComment = exampleComment;
	}

	public List<SearchDescriptorDTO> getAvailableSearches() {
		return availableSearches;
	}

	public void setAvailableSearches(List<SearchDescriptorDTO> availableSearches) {
		this.availableSearches = availableSearches;
	}

	public void setLinks(Map<String, String> links) {
		this.links = links;
	}

}
